package com.xcity.tools.badword;

import java.io.File;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

import naga.x.util.IOUtils;
import naga.x.util.IOUtils.LineReaderListener;
import naga.x.util.StringUtils;

public class AddNewBadWords {

	static File fileDir = new File("D:/temp/badwords");
	public static void main(String[] args) {
		try {
			System.setOut(new PrintStream(new File(fileDir, "output.txt")));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		Set<String> strSet = new HashSet<String>();
		
		File oldWords = new File(fileDir, "badwords.txt");
		IOUtils.read(oldWords, IOUtils.UTF8, new LineReaderListener() {
			@Override
			public boolean readLine(String line) {
				line = StringUtils.trim(line);
				if(!strSet.contains(line)){
					strSet.add(line);
				}
				return true;
			}
		});
		
		File newWords = new File(fileDir, "newwords.txt");
		IOUtils.read(newWords, IOUtils.GBK, new LineReaderListener() {
			@Override
			public boolean readLine(String line) {
				String[] strs = StringUtils.split(line, "、");
				for(String str : strs){
					str = StringUtils.trim(str);
					if(!strSet.contains(str)){
						strSet.add(str);
						System.out.println(str);
					}
				}
				return true;
			}
		});
	}

}
